<%@ page contentType="text/html; charset=utf-8" language="java"  errorPage="" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String op = request.getParameter("op");
if(null != op && op .equalsIgnoreCase("loginOut")){
	request.getSession().setAttribute("sessionObj", null);
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>NETCONF Development Toolkit</title>
	<meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <link rel="stylesheet" type="text/css" href="<%=basePath%>/css/index.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/items.css" />
    <script type="text/javascript"  src="<%=basePath %>jstree-v.pre1.0/_lib/jquery.js"></script>
</head>
<style type="text/css">
    body{
	   margin:0px;
	   padding:0px;
	   }
   .loginDiv{
	   border:1px solid;
	   border-color:#B3B3B3 #B3B3B3 #B3B3B3 #B3B3B3;
	   width: 500px;
	   position:absolute;
	   display:block;
	   padding:5px;
   }
   .loginTitle{
	   font-size:36px;
	   color:#5aa608;
	   text-align:center;
   }
   .loginSpan{
	   display:inline-block;
	   margin:0px 0px 8px 40px;;
	   width:120px;
	   text-align:left;
	   font-weight:bold;
   }
   .logonInput{
	   width:260px;
	   padding:2px;
	   height:20px;
   }
</style>

<body>

  <div class="loginDiv">
     <div class="loginTitle">用户登录</div>
       <form id="registerForm" action="LoginServlet" method="post">
       <div class="ListItem">
          <span class="loginSpan">8位工号：</span><input type="text" class="logonInput" id="_name" name="_name"  />
       </div>
       <div class="ListItem" style="text-align:right;">
            <span style="color:#AAA">
          	   如果没有修改过用户名，则登录名为注册时使用的8位工号。
          	 </span>
       </div>
       <div class="ListItem">
          <span class="loginSpan">密&nbsp;&nbsp;&nbsp;码：</span><input type="password" class="logonInput" id="_password" name="_password"  />
       </div>
        <div class="ListItem" style="text-align:right;">
            <span style="color:#AAA">&nbsp;
            测试帐号 —— 用户名： 10143951 , 密码： mj&nbsp;&nbsp;
          	</span>
       </div>
       <div class="ListItem" style="text-align:right;">
      
          <span class="textSpan">  
          	   <input type="button" id="loginButton" value="登录" onclick="checkForm()" />
               <input type="reset" value="重填" />
           </span>
           <span class="textSpan">
           <a href="register.jsp" id="registLink" > &gt;&gt; 用户注册</a>
           </span> &nbsp;&nbsp;&nbsp;&nbsp;
       </div>
       <%if(null != request.getAttribute("msg")){ %>
       <div class="ListItem" style="text-align:center;">
       <span style="color:#F00"><%=request.getAttribute("msg") %></span>
       </div>
       <%} %>
       </form>
  </div>
  
<script type="text/javascript">
function checkForm(){
       $("#_password").css("border-color","#000");
       $("#_name").css("border-color","#000");
	   document.getElementById("_password").value
	   if("" == document.getElementById("_password").value){
	       alert("密码不能为空！");
	       $("#_password").css("border-color","#F00");
	       document.getElementById("_password").focus();
		   return false;
	   }else if ("" == document.getElementById("_name").value){
	       alert("用户名不能为空！");
	       $("#_name").css("border-color","#F00");
	       document.getElementById("_name").focus();
		   return false;
	   }
	   
	   document.getElementById("registerForm").submit();
	   
}
  function LoadLogin(){
	screenwidth     = $(window).width();          
	screenheight    = $(window).height();                    //获取滚动条距顶部的偏移      
	mytop           = $(document).scrollTop();               //计算弹出层的left  
	var myheight    = $(".loginDiv").height();
	var mywidth     = $(".loginDiv").width(); 
	getPosLeft      = (screenwidth - mywidth)/2;             //计算弹出层的top        
	getPosTop       = (screenheight - myheight)/2-50 ; 
	$(".loginDiv").css({ "left": getPosLeft, "top": getPosTop });
  }
$(document).ready(function () {
	LoadLogin();
	$("#_password").keypress(function(e){
   		var curKey = e.which;
   		if(curKey == 13)
   		{
       		checkForm();
   		}
   });
});

</script>
</body>
</html>
